package com.itnoob.command1.example.task;

import com.itnoob.command1.example.service.CouponService;

/**
 * 具体命令类
 * @author zhoujun
 * @date 2025/3/18 23:24
 */
public class GetCouponTask implements Task{

    private CouponService couponService;

    private int userId;

    public GetCouponTask(CouponService couponService, int userId) {
        this.couponService = couponService;
        this.userId = userId;
    }

    /**
     * 实现执行方法
     * @return
     * @throws Exception
     */
    @Override
    public Object call() throws Exception {
        //调用接受者获取优惠券的方法,并返回结果
        return couponService.getCoupon(userId);
    }
}
